package cn.highset.modules.base.serviceimpl;

import cn.highset.modules.base.dao.VoteItemPraiseDao;
import cn.highset.modules.base.entity.VoteItemPraise;
import cn.highset.modules.base.service.VoteItemPraiseService;
import cn.hutool.core.collection.CollUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 投票活动明细投票记录接口实现
 *
 * @author Victor
 */
@Slf4j
@Service
@Transactional
public class VoteItemPraiseServiceImpl implements VoteItemPraiseService {

    @Autowired
    private VoteItemPraiseDao voteItemPraiseDao;

    @Override
    public VoteItemPraiseDao getRepository() {
        return voteItemPraiseDao;
    }

    @Override
    public VoteItemPraise findByVoteIdAndVoteItemIdAndUserid(String voteId, String voteItemId, String userid) {
        List<VoteItemPraise> list = voteItemPraiseDao.findByVoteIdAndVoteItemIdAndUserid(voteId, voteItemId, userid);
        return CollUtil.isNotEmpty(list) ? list.get(0) : null;
    }
}
